package com.wendu.工厂模式;


import com.wendu.工厂模式.Impl.Apple;
import com.wendu.工厂模式.Impl.Grape;
import com.wendu.工厂模式.Impl.Strawberry;

public class Factory {
    public static final int FACTORY_APPLE = 1;
    public static final int FACTORY_GRAPE = 2;
    public static final int FACTORY_STRAWBERRY = 3;
    private Factory(){
    }
    public static Fruit createFruit(int type){
        switch(type){
            case(FACTORY_APPLE):
               return new Apple();
            case(FACTORY_GRAPE):
                return new Grape();
            case(FACTORY_STRAWBERRY):
                return new Strawberry();
            default:
                throw new RuntimeException("不支持这种水果");
        }
    }

}
